package com.serverTechnology.teamsGroups.controller;


import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.serverTechnology.teamsGroups.entity.dto.TeCassetteAddDto;
import com.serverTechnology.teamsGroups.entity.dto.TeCassetteDto;
import com.serverTechnology.teamsGroups.entity.dto.TeCassetteEditDto;
import com.serverTechnology.teamsGroups.entity.vo.TeCassetteVo;
import com.serverTechnology.teamsGroups.service.ITeCassetteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.RandomAccess;

/**
 * <p>
 * 料盒台账 前端控制器
 * </p>
 *
 * @author 王凯炫
 * @since 2024-08-05
 */
@RestController
@RequestMapping("/cassette")
@ApiResource(name = "料盒台账接口")
@Api(tags = "料盒台账管理")
public class TeCassetteController {
    @Resource(name = "teCassetteServiceImpl")
    private ITeCassetteService iTeCassetteService;

    /**
     * 添加料盒台账
     * @return
     */
    @PostMapping("/add")
    @ApiOperation(value = "添加料盒台账")
    public ResponseData addTeCassette(@RequestBody @Validated TeCassetteAddDto teCassetteAddDto) {
        iTeCassetteService.addTeCassette(teCassetteAddDto);
        return new SuccessResponseData<>();
    }

    /**
     * 编辑料盒台账
     * @param teCassetteDto
     * @return
     */
    @PostMapping("/edit")
    @ApiOperation(value = "编辑料盒台账")
    public ResponseData editTeCassette(@RequestBody @Validated TeCassetteEditDto teCassetteDto) {
        iTeCassetteService.editTeCassette(teCassetteDto);
        return new SuccessResponseData<>();
    }

    /**
     * 查询料盒台账详情
     * @param id
     * @return
     */
    @GetMapping("/sel")
    @ApiOperation(value = "查询料盒台账详情")
    public ResponseData sel(Long id) {
        return new SuccessResponseData<>(iTeCassetteService.getById(id));
    }

    /**
     * 删除料盒台账
     * @param id
     * @return
     */
    @GetMapping("/del")
    @ApiOperation(value = "删除料盒台账")
    public ResponseData del(Long id) {
        iTeCassetteService.removeById(id);
        return new SuccessResponseData<>();
    }

    /**
     * 查询料盒台账列表
     * @param teCassetteDto
     * @return
     */
    @GetMapping("/page")
    @ApiOperation(value = "查询料盒台账列表")
    public ResponseData<PageResult<TeCassetteVo>> pageCassette(TeCassetteDto teCassetteDto) {
        return new SuccessResponseData<>(iTeCassetteService.pageCassette(teCassetteDto));
    }
}
